import random

from flask import Flask, render_template, make_response, redirect

app = Flask(__name__)
app.debug = True


@app.route("/create", methods=["post"])
def creat_room():
    """生成目标数字，创建房间号"""
    room_num = str(random.randint(1, 20))
    target_num = str(random.randint(1, 100))
    room_target_num = room_num + " " + target_num
    nums = []
    with open("room_tag.txt", "a+", encoding="utf-8") as f:
        f.write(room_target_num + "\n")
    with open("room_tag.txt", "r", encoding="utf-8") as g:
        while 1:
            r = g.readline()
            if r == "":
                break
            a, b = r.split(" ")
            nums.append([a, b])
        return render_template("index.html", msg2=nums)


@app.route("/")
def p():
    return render_template("index.html")


if __name__ == '__main__':
    print(app.url_map)
    app.run(host='0.0.0.0', port=5000)
